using System;
using System.Collections.Generic;
using System.Text;
using InTheHand.Net.Bluetooth;


class MiscFeatureTestCs
{
    static void Main(string[] args)
    {
        jarmhartWorkee();
        jarmhartOrig();
        ServiceElement e;
        e = new ServiceElement(ElementType.TextString, "Hello world");
        e = new ServiceElement(ElementType.TextString, new byte[] { (byte)'h', (byte)'i', });
        e = new ServiceElement(ElementType.Uuid16, (UInt16)0x1101);
    }

    static void jarmhartOrig()
    {
        // Serial port profile

        ServiceElement[] pSerialPortElements = new ServiceElement[2];

        pSerialPortElements[0] = new ServiceElement(ElementType.Uuid16, 0x1101);  // CRASHES
        /*
            System.ArgumentException was unhandled
              Message="CLR type 'Int32' not valid type for element type 'Uuid16'."
              Source="InTheHand.Net.Personal"
              StackTrace:
                   at InTheHand.Net.Bluetooth.ServiceElement.SetValue(Object value)
                   at InTheHand.Net.Bluetooth.ServiceElement..ctor(ElementTypeDescriptor etd, ElementType type, Object value)
                   at InTheHand.Net.Bluetooth.ServiceElement..ctor(ElementType type, Object value)
                   at MiscFeatureTestCs.Program.jarmhartOrig() in D:\Documents and Settings\alan\My Documents\Visual Studio 2005\Projects\32feet Top CodePlex\InTheHand.Net.Personal\Testing\MiscFeatureTestCs\Program.cs:line 24
                   at MiscFeatureTestCs.Program.Main(String[] args) in D:\Documents and Settings\alan\My Documents\Visual Studio 2005\Projects\32feet Top CodePlex\InTheHand.Net.Personal\Testing\MiscFeatureTestCs\Program.cs:line 13
                   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
                   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
                   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
                   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
                   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
                   at System.Threading.ThreadHelper.ThreadStart()
            */
        pSerialPortElements[1] = new ServiceElement(ElementType.UInt16, 0x100);
        /*
            System.ArgumentException was unhandled
              Message="CLR type 'Int32' not valid type for element type 'UInt16'."
              Source="InTheHand.Net.Personal"
              StackTrace:
                   at InTheHand.Net.Bluetooth.ServiceElement.SetValue(Object value)
                   at InTheHand.Net.Bluetooth.ServiceElement..ctor(ElementTypeDescriptor etd, ElementType type, Object value)
                   at InTheHand.Net.Bluetooth.ServiceElement..ctor(ElementType type, Object value)
                   at MiscFeatureTestCs.Program.jarmhartOrig()
                   at MiscFeatureTestCs.Program.Main(String[] args)
                   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
                   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
                   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
                   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
                   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
                   at System.Threading.ThreadHelper.ThreadStart()
        */

        ServiceElement Serial = new ServiceElement(ElementType.ElementSequence, pSerialPortElements);
    }

    static void jarmhartWorkee()
    {
        // Serial port profile

        ServiceElement[] pSerialPortElements = new ServiceElement[2];
        pSerialPortElements[0] = new ServiceElement(ElementType.Uuid16, (UInt16)0x1101);  // CRASHES

        pSerialPortElements[1] = new ServiceElement(ElementType.UInt16, (UInt16)0x100);
        // -or-
        pSerialPortElements[1] = ServiceElement.CreateNumericalServiceElement(ElementType.UInt16, 0x100);

        ServiceElement Serial = new ServiceElement(ElementType.ElementSequence, pSerialPortElements);
    }

}//class
